import { Injectable } from '@angular/core';
import { RequestClass } from './request.service';
@Injectable()
export class ApplicantService {
    constructor(private requestclass: RequestClass) {}
    fetchApplicantByName = async ({ applicant_name }) => {
        return await this.requestclass.request.Pget(
            '/applicant/getapplicantinfo',
            {
                params: {
                    applicant_name,
                },
            }
        );
    };

    addApplicantByName = async ({
        applicantName,
        cardId,
        category,
        coApplicant,
        code,
        contactPerson,
        departmentId,
        legalPerson,
        liveAddress,
        phone,
        productAddress,
        zoneId,
        zoneType,
    }) => {
        return await this.requestclass.request.post(
            '/applicant/insertapplicantinfo',
            {
                data: {
                    applicantName,
                    cardId,
                    category,
                    coApplicant,
                    code,
                    contactPerson,
                    departmentId,
                    legalPerson,
                    liveAddress,
                    phone,
                    productAddress,
                    zoneId,
                    zoneType,
                },
            }
        );
    };

    editApplicantByName = async ({
        applicantId,
        applicantName,
        cardId,
        category,
        coApplicant,
        code,
        contactPerson,
        departmentId,
        legalPerson,
        liveAddress,
        phone,
        productAddress,
        zoneId,
        zoneType,
    }) => {
        return await this.requestclass.request.put(
            '/applicant/updateapplicantinfo',
            {
                data: {
                    applicantId,
                    applicantName,
                    cardId,
                    category,
                    coApplicant,
                    code,
                    contactPerson,
                    departmentId,
                    legalPerson,
                    liveAddress,
                    phone,
                    productAddress,
                    zoneId,
                    zoneType,
                },
            }
        );
    };

    deleteApplicantById = async ({ applicantId }) => {
        return await this.requestclass.request.delete(
            '/applicant/deleteapplicantinfo',
            {
                params: {
                    applicantId,
                },
            }
        );
    };

    getWellById = async ({ applicantId }) => {
        return await this.requestclass.request.get('/applicant/getwellinfos', {
            params: {
                applicantId,
            },
        });
    };

    assignWellById = async ({ wellIds = [], applicantId }) => {
        return await this.requestclass.request.post('/applicant/assignwell', {
            data: wellIds.map((item) => {
                return {
                    wellId: item,
                    applicantId,
                };
            }),
        });
    };
}
